home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Cracking / HexEdit1.2.sit / ObjectWindow.c < prev    next >
Text File  |  1993-12-13  |  2KB  |  76 lines

  1. /*********************************************************************
  2.  * ObjectWindow.c
  3.  *
  4.  * A pre-c++ set of routines for implementing object-like windows.
  5.  *
  6.  * HexEdit, a simple hex editor
  7.  * copyright 1993, Jim Bumgardner
  8.  *********************************************************************/
  9. #include "ObjectWindow.h"
  10.  
  11. WindowPtr InitObjectWindow(short resID, ObjectWindowPtr theWindow, Boolean isFloating)
  12. {
  13.     WindowPtr wp;
  14.     if (theWindow == NULL) {
  15.         theWindow = (ObjectWindowPtr) NewPtrClear(sizeof(ObjectWindowRecord));
  16.         if (theWindow == NULL)
  17.             return NULL;
  18.         theWindow->ownStorage = true;
  19.     }
  20.     else
  21.         theWindow->ownStorage =false;
  22.     theWindow->floating = false;
  23.     wp = GetNewWindow(resID, (WindowPtr) theWindow, (WindowPtr) -1L);
  24.     ((WindowPeek) wp)->refCon = MyWindowID;
  25.     theWindow->Update = DefaultUpdate;
  26.     theWindow->Activate = DefaultActivate;
  27.     theWindow->HandleClick = DefaultHandleClick;
  28.     theWindow->Dispose = DefaultDispose;
  29.     theWindow->Draw = DefaultDraw;
  30.     theWindow->Idle = NULL;
  31.     ((ObjectWindowPtr) theWindow)->floating = isFloating;
  32.     return wp;
  33. }
  34.  
  35. void DefaultDispose(WindowPtr theWin)
  36. {
  37.     CloseWindow(theWin);
  38.     if (((ObjectWindowPtr) theWin)->ownStorage)
  39.         DisposPtr((Ptr) theWin);
  40. }
  41.  
  42. void DefaultUpdate(WindowPtr theWin)
  43. {
  44.     GrafPtr    savePort;
  45.     GetPort(&savePort);
  46.     SetPort(theWin);
  47.     BeginUpdate(theWin);
  48.     ((ObjectWindowPtr) theWin)->Draw(theWin);
  49.     EndUpdate(theWin);
  50.     SetPort(savePort);
  51. }
  52.  
  53. void DefaultActivate(WindowPtr theWin, Boolean active)
  54. {
  55.     GrafPtr    savePort;
  56.     GetPort(&savePort);
  57.     SetPort(theWin);
  58.     InvalRect(&theWin->portRect);
  59.     SetPort(savePort);
  60.     ((ObjectWindowPtr) theWin)->active = active;
  61. }
  62.  
  63. void DefaultHandleClick(WindowPtr theWin, Point where, EventRecord *er)
  64. {
  65. }
  66.  
  67. void DefaultDraw(WindowPtr theWin)
  68. {
  69. }
  70.  
  71. /************************************************************************************
  72.  * Routines for maintaining floating windows.                        
  73.  *
  74.  ************************************************************************************/
  75.  
  76.